package ducna.android.aoeclip.common.controller;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import ducna.android.aoeclip.R;

/**
 * Created by DUCNA on 11/4/2014.
 */
public class BaseFragment extends Fragment {
    private ProgressDialog mProgressDialog;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }
    // show dialog
    protected void initProgressDialog(){
        mProgressDialog = new ProgressDialog(getActivity());
        mProgressDialog.setTitle(R.string.app_name);
        mProgressDialog.setMessage(getResources().getString(R.string.please_wait));
        mProgressDialog.setCancelable(false);
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.show();
    }

    // dismiss dialog
    protected void hideProgressDialog(){
        if (mProgressDialog != null){
            mProgressDialog.dismiss();
            mProgressDialog = null;
        }
    }

    protected void showProgressDialog(){
        if (mProgressDialog != null)
            mProgressDialog.show();
    }
}
